﻿using AutoMapper;
using MediatR;
using ProcurementManagement.Applcation.Command.PurchaseReturnsCommand;
using ProcurementManagement.Domain.ProcurementDomain;
using ProcurementManagement.Infrstructre.Interface;

namespace ProcurementManagement.Applcation.CommandHanlers.PurchaseReturnsCommandHandler
{
    /// <summary>
    /// 修改实退采购款列表中介者
    /// </summary>
    public class UpdDirectRefundCommandHandler:IRequestHandler<UpdDirectRefundCommand,int>
    {
        private readonly lnterfaceDirectRefundRepository _directRefundRepository;
        private readonly IMapper _mapper;

        public UpdDirectRefundCommandHandler(lnterfaceDirectRefundRepository directRefundRepository, IMapper mapper)
        {
            _directRefundRepository = directRefundRepository;
            _mapper = mapper;
        }

        public async Task<int> Handle(UpdDirectRefundCommand request, CancellationToken cancellationToken)
        {
            return await _directRefundRepository.UpdataAsync(_mapper.Map<DirectRefund>(request.dto));
        }
    }
}
